home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / bin / do-release-upgrade < prev    next >
Text File  |  2009-11-02  |  2KB  |  62 lines

  1. #!/usr/bin/python2.6
  2.  
  3. import warnings
  4. warnings.filterwarnings("ignore", "apt API not stable yet", FutureWarning)
  5. import apt
  6.  
  7. from UpdateManager.Core.MetaRelease import MetaReleaseCore
  8. from UpdateManager.Core.DistUpgradeFetcherCore import DistUpgradeFetcherCore
  9. from optparse import OptionParser
  10. from gettext import gettext as _
  11. import time
  12. import sys
  13. import urllib2
  14. from DistUpgrade.utils import init_proxy
  15.  
  16. if __name__ == "__main__":
  17.  
  18.   init_proxy()
  19.  
  20.   parser = OptionParser()
  21.   parser.add_option ("-d", "--devel-release", action="store_true",
  22.                      dest="devel_release", default=False,
  23.                      help=_("Check if upgrading to the latest devel release "
  24.                           "is possible"))
  25.   parser.add_option ("-p", "--proposed", action="store_true",
  26.                      dest="proposed_release", default=False,
  27.                      help=_("Try upgrading to the latest release using "
  28.                             "the upgrader from $distro-proposed"))
  29.   parser.add_option ("-m", "--mode", default="server",
  30.                      dest="mode", 
  31.                      help=_("Run in a special upgrade mode.\n"
  32.                             "Currently 'desktop' for regular upgrades of "
  33.                             "a desktop system and 'server' for server "
  34.                             "systems are supported."))
  35.   parser.add_option ("-f", "--frontend", default="DistUpgradeViewText",
  36.                      dest="frontend", 
  37.                      help=_("Run the specified frontend"))
  38.   parser.add_option ("-s","--sandbox", action="store_true", default=False,
  39.                      help=_("Test upgrade with a sandbox aufs overlay"))
  40.  
  41.   (options, args) = parser.parse_args()
  42.  
  43.   print _("Checking for a new ubuntu release")
  44.   m = MetaReleaseCore(useDevelopmentRelease=options.devel_release,
  45.                       useProposed=options.proposed_release)
  46.   # this will timeout eventually
  47.   while m.downloading:
  48.       time.sleep(0.5)
  49.   if m.new_dist is None:
  50.       print _("No new release found")
  51.       sys.exit(1)
  52.   # we have a new dist
  53.   progress = apt.progress.TextFetchProgress()
  54.   fetcher = DistUpgradeFetcherCore(new_dist=m.new_dist,
  55.                    progress=progress)
  56.   fetcher.run_options += ["--mode=%s" % options.mode,
  57.                           "--frontend=%s" % options.frontend,
  58.                           ]
  59.   if options.sandbox:
  60.     fetcher.run_options.append("--sandbox")
  61.   fetcher.run()
  62.